<?php

namespace App\Http\Model\Admin;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class RoleMenu extends Model
{
    //  table name
    protected $table = 'role_menu';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'role_id', 'menu_id'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [

    ];


    /**
     * create batch
     *
     * @param  input object
     * @return  model
     */
    public function createBatch($input){
        return DB::table(self::getTable())->insert($input);
    }


    /*
     * delete batch
     *
     * @param role_id
     * @return model
     * */
    public function deleteBatch($role_id){
        if(self::where('role_id',$role_id)->count()){
            return self::where('role_id',$role_id)->delete();
        }
        return 1;
    }
    /**
     * find by ids
     *
     * @param  ids array
     * @return model
     */
    public function findByRoleIdArrs($ids){
        return self::whereIn('role_id',$ids)->get();
    }
}
